<template>
	<view class="container">
		<echarts :option="option" class="echarts"></echarts>
		<my></my>
		<my :content="content" num=20 :stu='stu'></my>
		<button type="default" @click="click">更新数据</button>
	</view>
</template>

<script>
	// 导入组件
	import echarts from '../components/echarts.vue'
	import my from '../components/my.vue'

	export default {
		data() {
			return {
				stu: {
					id: 1,
					name: '张三',
					age: 18
				},
				content: '这是一段从外面传入的内容',
				option: {
					title: {
						// text: 'ECharts组件示例'
					},
					tooltip: {},
					legend: {
						data: ['销量']
					},
					xAxis: {
						// data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
					},
					yAxis: {},
					series: [{
						name: '销量',
						type: 'bar',
						// data: [5, 20, 36, 10, 10, 20]
					}]
				},
			}
		},
		methods: {
			click() {
				this.option = {
					title: {
						text: '新的标题'
					},
					series: [{
						name: '销量',
						type: 'bar',
						data: [10, 20, 30, 40, 50, 60]
					}]
				}
			}
		},

		// 注册组件
		components: {
			echarts,
			my
		}
	}
</script>

<style>
	.container {
		width: 100%;
		height: 500upx;
	}
</style>